import { resolve } from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { viteCommonjs } from '@originjs/vite-plugin-commonjs'
import requireTransform from 'vite-plugin-require-transform';
import { vitePluginFakeServer } from 'vite-plugin-fake-server'
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    viteCommonjs(),
    requireTransform({ fileRegex: /^(?!.*node_modules).*\.(js|jsx|ts|tsx|vue)$/, }),
    AutoImport({
      resolvers: [
        ElementPlusResolver({
          importStyle: 'sass'
        })
      ]
    }),
    vitePluginFakeServer({
      logger: false,
      include: "mock",
      infixName: false,
      enableProd: true
    }),
  ],
  resolve: {
    alias: {
      '~/': `${resolve(__dirname, 'src')}/`,
      "@": `${resolve(__dirname, 'src')}/`
    },
    extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']

  },
  css: {
    preprocessorOptions: {
      scss: {
        // additionalData: `@use "~/assets/theme/default.scss" as *;`
        additionalData: '@import "@/assets/style/variable.scss";',

      }
    }
  },
  server: {
    port: 8088,
    host: "0.0.0.0",
    open: true,
    proxy: {},
    // proxy: {
    //   '/data-deal-website': {
    //     // target: 'http://10.19.85.6:9099', // 亚信云
    //     // target:'http://10.1.69.39:9099',
    //     // target:'http://192.168.110.50:8080', // 客户测试环境
    //     target: 'https://www.zzbdex.com', // 客户测试环境
    //     //target: 'http://www.core.zzbdex.com.cn', // 客户测试环境

    //     // target: 'http://wwww.zzbdex.com', // 客户生产环境
    //     // target: 'http://localhost:9099', // 杨亚
    //     ws: true,
    //     changeOrigin: true,
    //     // pathRewrite: {
    //     //   "^/data-deal-website": "/data-deal-website",
    //     // },
    //   },
    //   '/n-admin-api': {
    //     // target: 'http://10.19.85.6:9099', // 亚信云
    //     // target:'http://10.1.69.39:9099',
    //     // target:'http://192.168.110.50:8080', // 客户测试环境
    //     target: 'https://www.zzbdex.com', // 客户测试环境
    //     // target: 'http://wwww.zzbdex.com', // 客户生产环境
    //     // target: 'http://192.168.112.184:9099', // 杨亚
    //     ws: true,
    //     changeOrigin: true,
    //     // pathRewrite: {
    //     //   "^/data-deal-website": "/data-deal-website",
    //     // },
    //   },
    // },
  },
  build: {
    outDir: "data-platform-portal",
  }
})
